package com.example.androidhive;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;

public class Base_ extends AsyncTask<String,String,String>{
	private ProgressDialog pDialog;
	Activity aa;
	public void setAa(Activity aa) {
		this.aa = aa;
	}
	List<NameValuePair> params = new ArrayList<NameValuePair>();
	JSONParser jsonParser = new JSONParser();
	int wynik;
	//TESTTEST
	public int getWynik() {
		return wynik;
	}
	String url(String a){
		if(a!="" && a!=null)
			return new BASE().metoda(a);
		else
			return "";
	}
	Context ct;
	public Base_(Activity aa,String[] aaa,Context ctx) {
		this.aa = aa;
		this.aaa = aaa;
		this.ct=ctx;
	}
	@Override
	protected void onPreExecute() {
		super.onPreExecute();
		/*pDialog = new ProgressDialog(aa);
		pDialog.setMessage((aaa[0].substring(0,1)).toUpperCase()+aaa[0].substring(1)+"..");
		pDialog.setIndeterminate(false);
		pDialog.setCancelable(true);
		pDialog.show();*/
	}
	String[] aaa;
	public void setAaa(String[] aaa) {
		this.aaa = aaa;
	}
	@Override
	protected String doInBackground(String... arg0) {
		String[] cc=aaa[1].split(" ");
		for (String c:cc){
			String[] aa=c.split("-");
			params.add(new BasicNameValuePair(aa[0],aa[1]));
		} Intent i;
		i = new Intent(aa.getApplicationContext(), Polozenie.class);
		aa.startActivity(i);
		/*JSONObject json = jsonParser.makeHttpRequest("http://opiekuj1.javaprovider.net/php/logowanie.php",
				"POST", params);
		try {
			int success = json.getInt("success");
			wynik=success;	Intent i;
			switch(success){
			case 2://ok
				 i= new Intent(aa.getApplicationContext(), MojeDane.class);
				aa.startActivity(i);
				break;
			case 5://pierwsza rejestracja-zarejestrowano-ustalenie danych GPS
				i = new Intent(aa.getApplicationContext(), Polozenie.class);
				aa.startActivity(i);
				break;
			case 6://pierwsza rejestracja-zarejestrowano-ustalenie danych GPS
				i = new Intent(aa.getApplicationContext(), Polozenie.class);
				aa.startActivity(i);
				break;
			case 7:
				int a=0;
				break;
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}*/
		return null;
	}
	void a(){
		
	}
	protected void onPostExecute(String file_url) {
		//pDialog.dismiss();
	}

}
